Hi everybody.
In this video we analyze the pen that serious with non American value is so flexible String objects
like names and therefore we work with the Summer Olympics data set.
And first of all we import pandas and we import our Summer Olympic medal data set and we will have a
look at the first five rows so you can see here each row is actually a medal that was awarded during
a summer Olympic games.
And here in the columns we have and the year of the Olympic Games and the host city the sport the discipline
the athletes who won the medal.
So here in this example if it hires won the gold medal and he's from Hungary and he's the man and the
event was 100 meter freestyle and let's check also with the Inform method that we have in total thirty
one thousand one hundred sixty five meters then that were awarded from eighteen hundred ninety six to
2012 we have nine columns and we have more or less and no missing values only here in the country column
for missing values and our year column contains in the US and all of the other columns contain actually
String objects and now starting from our data frame here we can create a panel serious with the non
numerical values so for example we slice for the column athlete and we assign the column athlete to
the variable athlete.
So let's do this and first of all we can check and the type of our column here and it's the panda series
and let's have a look at the first five elements are rows of our panda serious.
So here we have them the values.
These are the athletes on the right side and on the left side.
We still have an index of our pandas data frame and we can also have a look at the last five rows
and we can also check the data type of them the values for the now pandas serious so to be here mastering
we have year 0 4 object.
So in simple words then we have an oh here it's very likely to String objects actually and we can also
check the shape of our panda serious and we have a one dimensional array so a panda seriousness always
one dimensional and we can also try to use and the described method and the described method gifts that's
actually different results compared to a numerical series.
So here for non numerical series we get first of all the total count of elements so we have thirty one
thousand one hundred sixty five athletes and twenty two thousand seven hundred sixty two we are actually
unique.
So we have many athletes that won more than one medal.
So for example Michael Phelps who is actually the top athlete who won the most medals and it's year
frequency.
You can see Michael Phelps 122 medals.
And we can also check here at the size of our pandas serious.
That's thirty one thousand one hundred sixty five and with the current method you can also check for
the amount of normal values.
And.
This will see the same as with the size as attribute.
So in our athlete column or panel series we do not have any missing or any end values.
So if we had any end values and then the count method here what does that return a lower value than
our size attribute.
And the difference would then be actually the amount of missing values and we can also try to apply
the min method so far in the map numerical serious we get to hear the minimum element and it's a non
numerical values we get here as a better clear the very first athlete and that's the guy.
I don't know how to pronounce it here but it starts with a double A B so alphabetically.
This athlete or sexually the very first athlete and we can also check our pandas serious for unique
values so we are all unique uh values are to say um athletes that won a medal in some Olympic Games
and we can also count the number of unique athletes with the lungs function is twenty two thousand seven
hundred sixty two and we can do the same with the method.
Any unique sort of awesome returns us yet twenty two thousand seven hundred sixty two
and it's unique.
We can decide whether we want to skip and missing on a values or not.
And we do not have any missing values here and our athletes series.
So the result should be the same actually.
So a default value is.
True.
And if we change to force so we should also look at the twenty two thousand seven hundred sixty two
because we do not have missing values.
All right.
And last but not least we can also use them here.
Father No no not in America.
I'm serious and the very powerful method value Collins
and what value Council actually does it returns us a panda serious with me actually.
The frequency of all values some that appear in our pandas series so.
Here we can see Michael Phelps is 22 times in our athlete pandas serious them.
That means that Michael Phelps 122 Olympic medals in his career and value counts by default returns
us here.
The frequency and sort of order.
So actually in descending order so the value with the highest frequency comes first here and that's
Michael Phelps and the second most successful athlete a seer laterals are Latina and so on here then
we can scroll down and in the end we end up with the athletes that won one gold medal here.
And with the ascending perimeter we can also change the order of sorting.
So here now we are starting with the athletes that won one medal and in the end we have here also Michael
Phelps
and we can also normalize our results to the 30 normalize perimeter so the normalized perimeter does
not return absolute frequencies but relative frequencies.
So we have some 31000 about medals and Michael Phelps won yeah only 0 point 0 0 7 0 6 percent of all
medals.
All right now we are finished with this session and the next session we will see and learn how to create
panic serious.
So hope to see you there by.